package top.lixunda.ecommerce.server.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import top.lixunda.commerce.common.core.entity.MessageObject;
import top.lixunda.ecommerce.server.business.BaseController;
import top.lixunda.ecommerce.server.business.api.entity.cache.CacheUser;
import top.lixunda.ecommerce.server.user.api.entity.db.LogChangePassDO;
import top.lixunda.ecommerce.server.user.api.controller.ILogChangePassController;
import top.lixunda.ecommerce.server.user.service.ILogChangePassService;

import java.util.List;

/**
 * @author Xumda
 * @version time:2019/12/16 14:31
 */
@RestController
@Slf4j
public class LogChangePssController extends BaseController implements ILogChangePassController {

    private final ILogChangePassService logChangePassService;

    @Autowired
    public LogChangePssController(ILogChangePassService logChangePassService) {
        this.logChangePassService = logChangePassService;
    }

    @Override
    public MessageObject<List<LogChangePassDO>> queryCurrentChangePass() {
        CacheUser detail = currentUserCacheNotNull();
        List<LogChangePassDO> logChangePassList = logChangePassService.list(
                new LambdaQueryWrapper<LogChangePassDO>()
                        .eq(LogChangePassDO::getAccount, detail.getAccount()));
        return getSuccessMessageObject("获取数据数据成功", logChangePassList);
    }
}
